<?php

header("Content-type: image/png");
$string = $_REQUEST['q'];
$string = substr($string, 0, 50);

$font_size = 5;
$width  = imagefontwidth($font_size)*strlen($string); 
$height = imagefontheight($font_size); 

$im = imagecreatetruecolor($width, $height);
imagealphablending($im, FALSE);
imagesavealpha($im, TRUE);

$bg_color = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefilledrectangle ($im, 0, 0, $width, $height, $bg_color);

$len = strlen($string);
for($i=0;$i<$len;$i++)
{
    $x = $i * imagefontwidth($font_size);
    $y = 0;
    
    $color = imagecolorallocatealpha($im, rand(0,255), rand(0,255), rand(0,255), 0);
    imagechar($im, $font_size, $x, $y, $string, $color);
    $string = substr($string, 1);
} 

imagepng($im);
imagedestroy($im);

?>
